const setLocalStorage = (key, value) => {
    if (value instanceof Array || value instanceof Object) {
        value = JSON.stringify(value)
    }
    localStorage.setItem(key, value)
}

const getLocalStorage = (key) => {
    var val = localStorage.getItem(key);
    var reg = /^[\[{].*[\]}]$/
    if (reg.test(val)) {
        val = JSON.parse(val)
    }
    return val
}